/*
 * @Author: chentao 
 * @Date: 2022-05-16 14:47:21 
 * @Last Modified by: chentao
 * @Last Modified time: 2022-05-17 16:57:04
 */
class FunctionClassTest {
    private num1: string;
    private num2: number;


    public add(num1: number, num2: number): number;
    public add(num1: any[], num2: any[]): any[];

    // public add(num1: number, num2: number):number {
    //     return num1+num2;
    // }

    // public add(num1: any[], num2: any[]): any[]{
    //     return [...num1, ...num2]
    // }

    public add(x: number | any[], y: number | any[]): any {
        if (typeof x === 'number' && typeof y === 'number') {
            return x + y;
        }
        if (Array.isArray(x) && Array.isArray(y)) {
            return [...x, ...y]
        }
    }

    public concatTotal(num1: string, num2: number): string;
    public concatTotal(num1: any[], num2: any[]): any[];

    public concatTotal(num1: string | number | any[], num2: string | number | any): any {

        if (typeof num1 === 'number' && typeof num2 === 'number') {
            return `数值求和:${num1 + num2}`;
        }
        if ((typeof num1 === 'string' && typeof num1 === 'string') ||
            (typeof num1 === 'number' && typeof num2 === 'string') ||
            (typeof num1 === 'string' && typeof num2 === 'number')
        ) {
            return `拼接字符串num1:${num1}and ${num2}`
        }
        if (Array.isArray(num1) && Array.isArray(num2)) {
            return [...num1, ...num2]
        }

    }
}

const test = new FunctionClassTest()
const resultInfo = test.concatTotal("张无忌", 23);
console.log(`resultInfo:${resultInfo}`)